home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / LGP250S1.ZIP / src / libgplus.5 / libgplus / test-ins / foo_main.cc < prev    next >
C/C++ Source or Header  |  1992-05-14  |  1KB  |  41 lines

  1. // main program for Class Foo
  2.  
  3. extern "C" {
  4. // Some <assert.h> implementations (e.g. SUNOS 4.1) are broken,
  5. // in that they require <stdio.h>.  But, if gcc/g++ is installed
  6. // correctly, you should get gcc's assert.h.
  7. // If the compile fails, it means the wrong include files are in use!
  8. #include <assert.h>
  9. };
  10. #include "Foo.h"
  11.  
  12. extern "C" void __init_start();
  13.  
  14. extern Foo f(void);
  15. extern void g(void);
  16.  
  17. /* This function should *not* be called by the environment.  There is
  18.    no way in C++ to ``run something after the initializers but before main()''.
  19.    The library that depends on this (NIHCL) is broken.  -- John Gilmore 
  20.    We leave this here to test that future changes to the compiler
  21.    do not re-introduce this losing ``feature''.  */
  22. void 
  23. __init_start()
  24. {
  25.     Foo::init_foo();
  26. }
  27.  
  28. static Foo static_foo( "static_foo"); 
  29.  
  30. main() 
  31.     assert (Foo::nb_foos() == 2);
  32.     Foo automatic_foo( "automatic_foo");
  33.     Foo bla_foo = f();
  34.     assert (Foo::nb_foos() == 4);
  35.     g();
  36.     assert (Foo::nb_foos() == 4);
  37.     // `automatic_foo' and `bla_foo' are destructed here 
  38.  
  39.